package it.gat.webservice.resource.impl;

import java.sql.SQLException;
import java.util.List;

import it.gat.dao.TicketDAO;
import it.gat.model.Ticket;
import it.gat.util.dao.DAOFactory;
import it.gat.webservice.utils.Impostazioni;

import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;

public class TicketsAssegnatiResource extends ServerResource {

	@Get
	public Ticket[] getAll() {
		DAOFactory daoFactory = DAOFactory.getDAOFactory(Integer.parseInt(Impostazioni.getProperty("DB_TYPE")));
		TicketDAO ticketDAO = daoFactory.getTicketDAO();
		List<Ticket> tickets;
		try {
			tickets = ticketDAO.retrieveTicketsAssegnati();
		} catch (SQLException e) {
			return null;
		}
		return tickets.toArray(new Ticket[0]);
	}
	

}
